package com.ruoyi.business.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.business.domain.LawyerTime;
import com.ruoyi.business.service.ILawyerTimeService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 律师的可服务时间Controller
 * 
 * @author liwenjing
 * @date 2021-05-20
 */
@RestController
@RequestMapping("/business/lawyertime")
public class LawyerTimeController extends BaseController
{
    @Autowired
    private ILawyerTimeService lawyerTimeService;

    /**
     * 查询律师的可服务时间列表
     */
    @GetMapping("/list")
    public TableDataInfo list(LawyerTime lawyerTime)
    {
        startPage();
        List<LawyerTime> list = lawyerTimeService.selectLawyerTimeList(lawyerTime);
        return getDataTable(list);
    }

    /**
     * 导出律师的可服务时间列表
     */
    @PreAuthorize("@ss.hasPermi('business:lawyertime:export')")
    @Log(title = "律师的可服务时间", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(LawyerTime lawyerTime)
    {
        List<LawyerTime> list = lawyerTimeService.selectLawyerTimeList(lawyerTime);
        ExcelUtil<LawyerTime> util = new ExcelUtil<LawyerTime>(LawyerTime.class);
        return util.exportExcel(list, "time");
    }

    /**
     * 获取律师的可服务时间详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(lawyerTimeService.selectLawyerTimeById(id));
    }

    /**
     * 新增律师的可服务时间
     */
    @PreAuthorize("@ss.hasPermi('business:lawyertime:add')")
    @Log(title = "律师的可服务时间", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody LawyerTime lawyerTime)
    {
        return toAjax(lawyerTimeService.insertLawyerTime(lawyerTime));
    }

    /**
     * 修改律师的可服务时间
     */
    @PreAuthorize("@ss.hasPermi('business:lawyertime:edit')")
    @Log(title = "律师的可服务时间", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody LawyerTime lawyerTime)
    {
        return toAjax(lawyerTimeService.updateLawyerTime(lawyerTime));
    }

    /**
     * 删除律师的可服务时间
     */
    @PreAuthorize("@ss.hasPermi('business:lawyertime:remove')")
    @Log(title = "律师的可服务时间", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(lawyerTimeService.deleteLawyerTimeByIds(ids));
    }
}
